Copyright: Copyright © Cyborg Software
Citation: by Boris


Add to Project

This option adds the PAS file to the current Project selected in the Delphi IDE


As you go along

You may use Cyborg String Expert during the normal course of writing software. If you get to a point in the code where you need to refer to a string constant, you could proceed as follows

1	Place the Insertion point at the right spot in the source where you want the string

2	Start the String Expert {Alt-H, S}

3	Open the new string dialog box {File | New Item or Ctrl-I}

4	Type in the string you need. When satisfied, press Enter {CR}

5	If you wish to paste a function call to load the string from the RES file, use {Edit | Paste Loader Call or Ctrl -L}

or you can use the same techniques for retrofitting


AutoRun

Check this check box to cause the Resource Compiler to compile the RC file every time the program exits


AutoSave

Use this option to ensure that the PAS & RC files are saved every time you close the String Expert Window


Boris Ingram

Cyborg Software

104 Ernest Rd

Kensington , 2094

Johannesburg

South Africa

Email : 	borising@iafrica.com

100076,3616@compuserve.com

WWW	http://www.pcb.co.za/users/borising/cyborg.htm

Voice +27 11 622 6056

Fax +27 11 616 4257


By File
Reading existing RC Files

Cyborg String Expert uses standard RC files to store strings - so it is very simple to load an existing RC file.

Choose the appropriate RC file in the {Options | RC/ RES File Edit}. Use the browse button if required

Use  File Open command to load the RC file


CYBSTREX.INI

The string expert uses INI files to keep info between runs. 2 separate INI files of the same name are used.

C:\Windows\cybstrex.ini keeps the positions of all windows used

A local cybstrex.ini is created in each project directory. This INI file keeps all the options that are selected in the Options dialog, plus the widths of the grid columns. To ensure that the String Expert brings up the appropriate string table, this INI file must be found in each project's directory.

Projects that use multiple RES files - multilingual projects - will require some INI file juggling.


Clear All

After confirming your intention, this option will remove all strings from the string table.


ClipBoard
ClipBoard Functions

Standard Windows ClipBoard functions of Cut, Copy and Paste are implemented.

Cut & Copy will place only the string itself on the clipboard - the ID number & constant name are not transferred

Paste will insert any string in the clipboard into the string table, and automatically assign the next ID, and create a constant name for the new resource


Compile RES file

Use this option to invoke the Resource Compiler Program

To determine success of the Compilation, you will need to manually check the RES file's date & time. Error codes returned by BRCC.EXE or BRCC32.EXE could not be determined.


Contents

Cyborg Software's String Expert is a native Delphi Expert that hugely simplifies creating & maintaining String tables, resource files and files of access constants. The advantages of using string resources rather than embedded constants are well documented, but Delphi as shipped makes no allowance for dealing with string tables, except for a resource compiler.

String Expert makes string table resources easily available within the Delphi IDE at design time. It appears as "Cyborg String Expert ..." on the Delphi IDE's Help Menu, when correctly installed, and brings easy handling of every projects string resources right to your finger tips.

Using String Expert

String Expert is a true 2 way tool, in best Borland & Delphi tradition. It saves all string data in either the RC file or a PAS file. Both of the specified files are reloaded each time you invoke the expert. This means any changes with the source editor to either of these files are immediately reflected in the string table.

It also ensures that you do not store duplicate strings.

The string expert supports several modes of accumulating all strings for a project into an RC file. You may add strings as you write your source . You may wish  to retrofit  RES file string tables to a project that has strings embedded in the source. You can also incorporate strings  by importing text files. If you already have some strings in an RC file, you may read these existing RC files into the string table

License & Registration

The free version has a maximum limit of 20 strings. The share ware version of String Expert is unlimited, and comes with full source code. Please register your copy  and you will also receive free upgrades for a year.

Written by Boris Ingram

Version 1	20 April 1997


Contents Recursion !!!


Down Button

If the order that the strings appear in the list is important, then use this button or the Up Button to set the order of strings.

You may use the Tools | Renumber command in conjunction with these buttons


Edit Menu
Cut

Copy

Paste

Paste Loader Call

Clear All

--

Find

Find Again


File Browse Button

Press this button to get an Open Dialog to ease selecting the file


File Exit

Exit the Expert, back to the Delphi IDE


File Menu
New

New Item

Open

Save

--

Exit


File New

This creates a new string table for the Delphi project.

It clears any existing strings , and the displays the Options dialog so you may set preliminary options for the new project


File New Item

This allows adding a new string to the string table. A simple dialog opens, and anything typed is taken as the new string, except for ' (single inverted comma's).  Any Single inverted commas are automatically removed from the string

BRCC has rules about embedding of particular characters in strings. Including these disallowed characters may cause the compiler to fail in compiling the RES file. However, I do not have information about what these are - I know you may not use \ (backslash) and there may be others.


File Open

This opens the RC / PAS file pair. Firstly CYBSTREX.INI is opened to determine the names of these files.

The RC file is read first, if one exists. It is parsed for the string & ID numbers. If the PAS file exists, this is also read so that these ID numbers may be used to look up the constant names associated with each string

As String Expert uses Delphi tstringlists to load files, every String in the RC file & every constant Name in the PAS file must be on their own line, or else File Open may fail to parse these files correctly. eg

   some_StrID = 30;  Another_StrID = 40;  YetAnother_StrID = 60;

While the above line would compile fine in Delphi, it will totally confuse the String Expert. Rather use

some_StrID = 30;

Another_StrID = 40;

YetAnother_StrID = 60;


File Save

Saves the RC / PAS file pair to disk, in the names given in Options | File Names


Find

Shows the Find dialog. Any of either the String OR the ID number OR the constant name can be searched, but not simultaneously. The string table is always searched from top to bottom.

The search mechanism searches for any characters typed ANYWHERE within the searched string - it does not only show strings that begin with the entered string.  It is case sensitive.

The search entered above will find all of :

Mastodon

Fonn

Onomatopoeia

Condom

where they exist in the Strings Column

Use Find Again or F3 to continue the search.


Find Again

This option continues the search defined in the Find Dialog


Help Menu
Contents

Related Topics

About


ID

The ID number is the Integer value used by both the PAS and RC files to number each string.


ID Placement

This radio button group determines whether any string type for the constant name differentiator is appended to the front of the ID created from the string (prefix) or placed at the end (suffix)


LoadString Function Name

The name of the Pascal function that is called to actually load the string from RES file at run time. The function name will be pasted into the source code. The default values is "LoadStr" - the Delphi standard function to load strings

If you wish to use another function name that may take additional parameters, ensure that the ID number parameter is last in the functions parameter list eg

if you had a String ID constant Name of "fred_StrID"

if you set function name to "myloadstring(someotherparam, ", the  Paste Loader Call  would paste the following into your source code

myloadstring(someotherparam, fred_StrID);


Menus
File

Edit

Tools

Help


New & Paste

This option combines 2 common functions in one. It first solicits a new string by showing the same dialog as in File | New Item. If you accept the string {by clicking the OK button or the CR key}, this string is added to the list, and the appropriate loader call is pasted. String Expert closes after pasting

Particularly useful when retrofitting


Offset

This value is the offset number that will be added to each ID number. This means you can assign ID numbers in a range that will not conflict with other numbers.

Useful with the Renumber Option


Onomatopoeia

I know it won't find this word, being case sensitive, but I first though it would, and have been sparked a bit by the word, and so here it stays


Options


Output Unit Name

The Name of the file where the PAS file will be stored. This file contains constant names and associated ID numbers


Paste Loader Call

This causes an appropriate loader call for the currently selected Grid row to be pasted into the Delphi Source Code. If you invoke this command while the following screen is displayed

will cause the following to appear at the insertion point of the Delphi Editor

Loadstr(StringExpert_StrID)

assuming that the loader function name is Loadstr.

If the string is duplicated in the string table, then constant name will be suffixed with a number.


RES/RC File Name

The String Editor uses 2 files to manage your string table - an RC file, where the actual strings are stored with an ID number. This is the primary files used - see File Open. If a PAS file is specified, this is used to determine any constant names used.

It is quite possible (and useful) to use multiple RC files with a single PAS file - this would be the case in a multilingual project.


ReNumber

Choosing this option causes all the ID numbers for strings to be recalculated. The first String is given the Offset number, and each string numbered sequentially after that.

You may freely renumber your list - this is the point of using a PAS / RC file combination to manage string tables - it allows you complete freedom for ID number, as the ID number is never referred to directly.


Read Text File

This allows importing of ASCII text files into the string table. Select the file required from the Open Dialog that appears

Strings from text files are appended to the existing list. ID numbers and constant names are automatically calculated


Register your Copy

This limited free version of Cyborg String Expert may be freely distributed in it's original zip file.

Registering for a shareware version will remove the 20 string limit, includes source code and I will provide any upgrades free of charge for 1 year.

For CompuServe members, easiest registration is via the Shareware Forum - GO SWREG. Cyborg String Expert shareware cost $ 25 US, with no additional handling fee for E mailed source code & documentation.

For people without CompuServe accounts, you may register by direct money transfer, preferably using SWIFT. Any bank transfer fees , commissions are excluded from the price. Please contact me by Email for bank details .


Related Topics

These are some topics in other Delphi Help files. Due to quirky help author behaviour, these jumps need to be made by the app, not within winhelp

from Delphi.hlp

Resource File Directive

LoadStr function

Identifiers"

from winapi.hlp"

compiling resources

String-Table Resources"


Resource Compiler Name

The name of the resource compiler - either BRCC.EXE by default for Delphi 1 or BRCC32.EXE for Delphi 2.

Any other compiler could also be used, if it could take a file name as a command line parameter.


Retrofitting

String Editor is quite useful for changing projects which have string constants embedded in the source code to one where the strings are in a RES file string table. My scheme is as follows

1	Open the offending file in the Delphi Editor. Search for ' (single inverted comma)

2	On finding a string that you want added to the RES file, select the entire string, including it's inverted comma's. Cut or Copy it to the clipboard (Ctrl-X, Ctrl-C or Shift-Del, Ctrl-Ins)

3	Invoke the String Expert - mouse click or Alt-H, S

4	Invoke the New & Paste utility (Ctrl-N)

5	Paste the string into the edit dialog (Ctrl-V or Shift-Ins). Close the dialog by mouse or the enter key.

6	The loader call is pasted into you code in place of the string. Press F3 to find the next string

You can continue this process quite quickly, if you,learn all the key strokes.

Roll on a Delphi Editor Macro facility !


Storing Duplicate Strings.
Storing Duplicate Strings

String Expert maintains a list of constant names, and ensures that each constant name is unique. It does this by appending an additional digit, starting at 0, and continuing up to 99, to the string to ensure uniqueness. This is exactly as Delphi does when duplicate components are dropped on a form.

Because each constant name is derived from the string it represents (and there are definite advantages to keeping this scheme), then when a string is duplicated in the list, it's constant name will have a digit at the end. This will be apparent when you Paste the Loader call into your source

In this case,  edit the string table and cut the duplicate string table entry. You will also need to edit the string loader call to remove the digit


String Count

This is the count of strings in the string table. Be aware that numbering of strings starts at 0, thus the last displayed ID will be the count - 1.


Strings

This column shows the actual strings that will be stored in the RES file, and which will appear in response to the LoadStr function call


Text Files

You may wish to include some strings from a text file into your EXE. Cyborg String Expert can insert a text file into your String table, automatically generating an ID number and constant name for the ID number.

Use Tools | Read text file to read an existing text file into the string table


Tools menu
New & Paste

Add to Project

ReNumber

Read Text File

Compile RES file

Options


Up Button

Used to move strings higher up in the string table order. See Also Down Button & Renumber


Using String Table Resources

The jumps in this section of help don't work because my help author refuses to allow embedded spaces in the topic of an external help file.  See Help | Related Topics

To use string table resources in Delphi projects you need to do several things

1	<broken jump> Create a RES file <broken jump>  from an RC File. Delphi is shipped with BRCC & BRCC32.

2	Include a <broken jump>{$R Filename}<broken jump>  directive in a unit

3	Use loadstr to load the string from the resource file


advantages of using string resources

Reasons to use string table resources

1	Saves Data Segment for 16 bit Apps - store an integer, not the whole string in the DS

2	Portability - you can relatively simply change languages

3	Documentation generation - it is easier to write things like documentation if you know what messages  will appear


Constant

A constant name assigned to the ID number in the PAS file. This name is created from the string by removing characters not permitted in a Delphi constant name

String Expert ensures that all constant names are unique within each project.


Constant ID

This optional string can be appended to the end of the constant name as generated by String Expert. If you are using literal strings that may also be Delphi reserved words, then you will need some value here, else the project will not compile e.g.

If you have a literal string "Interface", the if the constant Identifier is empty, a const line in the PAS file will read

Const

Interface = 20034;

This will not compile. If you add a suffixed constant ID of "_StrID" (the default), the PAS file contain

Interface_StrID = 20034;

which will compile fine.